package com.tencent.ied.bk.handler.impl;

import com.tencent.ied.bk.handler.Handler;
import com.tencent.ied.bk.handler.HandlerObject;

/**
 * @author chen_yu
 * @date 2021/3/11 6:51
 */
public class SortHandler implements Handler {
    @Override
    public void handle(HandlerObject handlerObject) {
        handlerObject.getSearchAbstractInfoList().sort((o1, o2) -> {
            //4、搜索次数最高的摘要排在最前面。
            int compareRes1 = o2.getSearchCount().intValue() - o1.getSearchCount().intValue();
            if (compareRes1 != 0) {
                return compareRes1;
            }
            int compareRes2 = o2.getSearchKeyWordCountInContent().compareTo(o1.getSearchKeyWordCountInContent());
            if (compareRes2 != 0) {
                return compareRes2;
            }
            int compareRes3 = o2.getSearchContainsKeyWordCountInContent().compareTo(o1.getSearchContainsKeyWordCountInContent());
            if (compareRes3 != 0) {
                return compareRes3;
            }
            return o1.getContent().length() - o2.getContent().length();
        });
    }
}
